package com.fy.controller;

import com.fy.dao.GoodsMapper;
import com.fy.dao.User_infoMapper;
import com.fy.entity.Goods;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    String id = "1";
    @Resource
    GoodsMapper goodsMapper;
    @Resource
    User_infoMapper userInfoMapper;

    @GetMapping("/getAll")
    public List<Goods> findAll() {
        return goodsMapper.findAll();
    }

    @PostMapping("/getInfo")
    public List<Goods> getInfo(String go_id) {
        return goodsMapper.getInfo(go_id);
    }

    @PostMapping("insert")
    public String insert_goods(String go_id, String info_id, String go_fm, String go_pic,
                               String go_info, String go_title, String go_type) {
        goodsMapper.insert_goods(id, info_id, go_fm, go_pic, go_info, go_title, go_type);
        id=(Integer.valueOf(id)+1+"");
        userInfoMapper.update_info(null, null, null, null, 1, info_id);
        return "200";
    }

}
